#include "ostree-repo-private.h"
#include "otutil.h"
+#include "ot-fs-utils.h"
static gboolean
add_ref_to_set (const char *remote,
return ret;
}
-static gboolean
-openat_ignore_enoent (int dfd,
- const char *path,
- int *out_fd,
- GError **error)
-{
- gboolean ret = FALSE;
- int target_fd = -1;
-
- target_fd = openat (dfd, path, O_CLOEXEC | O_RDONLY);
- if (target_fd < 0)
- {
- if (errno != ENOENT)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
- }
-
- ret = TRUE;
- *out_fd = target_fd;
- out:
- return ret;
-}
-
static gboolean
find_ref_in_remotes (OstreeRepo *self,
const char *rev,
if (!glnx_opendirat (dfd_iter.fd, dent->d_name, TRUE, &remote_dfd, error))
goto out;
- if (!openat_ignore_enoent (remote_dfd, rev, &ret_fd, error))
+ if (!ot_openat_ignore_enoent (remote_dfd, rev, &ret_fd, error))
goto out;
if (ret_fd != -1)
{
const char *remote_ref = glnx_strjoina ("refs/remotes/", remote, "/", ref);
- if (!openat_ignore_enoent (self->repo_dir_fd, remote_ref, &target_fd, error))
+ if (!ot_openat_ignore_enoent (self->repo_dir_fd, remote_ref, &target_fd, error))
goto out;
}
else
{
const char *local_ref = glnx_strjoina ("refs/heads/", ref);
- if (!openat_ignore_enoent (self->repo_dir_fd, local_ref, &target_fd, error))
+ if (!ot_openat_ignore_enoent (self->repo_dir_fd, local_ref, &target_fd, error))
goto out;
if (target_fd == -1)
{
local_ref = glnx_strjoina ("refs/remotes/", ref);
- if (!openat_ignore_enoent (self->repo_dir_fd, local_ref, &target_fd, error))
+ if (!ot_openat_ignore_enoent (self->repo_dir_fd, local_ref, &target_fd, error))
goto out;
if (target_fd == -1)
#include "ostree-repo-file-enumerator.h"
#include "ostree-gpg-verifier.h"
#include "ostree-repo-static-delta-private.h"
+#include "ot-fs-utils.h"
#ifdef HAVE_LIBSOUP
#include "ostree-metalink.h"
return ret;
}
-static gboolean
-openat_allow_noent (int dfd,
- const char *path,
- int *fd,
- GCancellable *cancellable,
- GError **error)
-{
- GError *temp_error = NULL;
-
- if (!gs_file_openat_noatime (dfd, path, fd,
- cancellable, &temp_error))
- {
- if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
- {
- *fd = -1;
- g_clear_error (&temp_error);
- }
- else
- {
- g_propagate_error (error, temp_error);
- return FALSE;
- }
- }
- return TRUE;
-}
-
static gboolean
load_metadata_internal (OstreeRepo *self,
OstreeObjectType objtype,
_ostree_loose_path (loose_path_buf, sha256, objtype, self->mode);
- if (!openat_allow_noent (self->objects_dir_fd, loose_path_buf, &fd,
- cancellable, error))
+ if (!ot_openat_ignore_enoent (self->objects_dir_fd, loose_path_buf, &fd,
+ error))
goto out;
if (fd < 0 && self->commit_stagedir_fd != -1)
{
- if (!openat_allow_noent (self->commit_stagedir_fd, loose_path_buf, &fd,
- cancellable, error))
+ if (!ot_openat_ignore_enoent (self->commit_stagedir_fd, loose_path_buf, &fd,
+ error))
goto out;
}
struct stat stbuf;
g_autoptr(GInputStream) tmp_stream = NULL;
- if (!openat_allow_noent (self->objects_dir_fd, loose_path_buf, &fd,
- cancellable, error))
+ if (!ot_openat_ignore_enoent (self->objects_dir_fd, loose_path_buf, &fd,
+ error))
goto out;
if (fd != -1)
}
return TRUE;
}
+
+gboolean
+ot_openat_ignore_enoent (int dfd,
+ const char *path,
+ int *out_fd,
+ GError **error)
+{
+ gboolean ret = FALSE;
+ int target_fd = -1;
+
+ target_fd = openat (dfd, path, O_CLOEXEC | O_RDONLY);
+ if (target_fd < 0)
+ {
+ if (errno != ENOENT)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+ }
+
+ ret = TRUE;
+ *out_fd = target_fd;
+ out:
+ return ret;
+}
const char *path,
GError **error);
+gboolean ot_openat_ignore_enoent (int dfd,
+ const char *path,
+ int *out_fd,
+ GError **error);
+
G_END_DECLS